import { SET_ADDRESS, SET_TOKEN, SET_USERINFO } from '../constants/positioning'

const INITIAL_STATE = {
    address: {
        latitude: 0,
        longitude: 0,
        address: '上海宏烨校区',
        name: ''
    },
    token: '',
    userInfo: {},
}

export default function counter(state = INITIAL_STATE, action) {
    const { type, payload } = action;
    switch (type) {
        case SET_ADDRESS:
            return {
                ...state,
                address: { ...payload }
            }
        case SET_TOKEN:
            return {
                ...state,
                token: payload
            }
        case SET_USERINFO:
            return {
                ...state,
                userInfo: payload
            }
        default:
            return state
    }
}
